
*********************************
***   Economic and Interest   ***
*********************************

est clear
local economic economic_index employed assets basic_necessities 

foreach var of varlist `economic' {
	display " "
	display " "
	display " "
	display "Table 1a: `var'"
	quietly eststo: areg `var' instrument $controls if birthyear_control >= 1970 & birthyear_control <= 1997, absorb(locale_gender) cluster(locale_3_control)
	noisily: lincom instrument
	quietly: summ `var'
	estadd scalar vmean = r(mean)

}


local information information interest_pub_affairs_index discuss_pol_index news_scale

foreach var of varlist `information' {
	display " "
	display " "
	display " "
	display "Table 1b: `var'"
	quietly eststo: areg `var' instrument $controls if birthyear_control >= 1970 & birthyear_control <= 1997, absorb(locale_gender) cluster(locale_3_control)
	
	noisily: lincom instrument
	quietly: summ `var'
	estadd scalar vmean = r(mean)
	
}


local numbers "& (1) & (2) & (3) & (4) \\"
local economic "\textbf{A: Economic} & \multicolumn{1}{c}{Economic index} &  \multicolumn{1}{c}{Employed}  &  \multicolumn{1}{c}{Assets index}  &  \multicolumn{1}{c}{Basic necessities index} \\  \midrule"
local interest "\midrule \\ \textbf{B: Interest} & \multicolumn{1}{c}{Interest index} &  \multicolumn{1}{c}{Interest in pub affairs}  &  \multicolumn{1}{c}{Discuss politics}  &  \multicolumn{1}{c}{News index} \\  \midrule"
local gap ""

esttab est1 est2 est3 est4 using "tables/econ_interest.tex", replace b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) nonumber posthead("`numbers'" "`economic'") ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument)

esttab est5 est6 est7 est8 using "tables/econ_interest.tex", b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) ///
nonumber posthead("`gap'" "`interest'") append ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument)





*************************
***   Participation   ***
*************************

local participation participation_index participate_index contact_index 

est clear

foreach var of varlist `participation' {
	display " "
	display " "
	display " "
	display "Table 2a: `var'"
	quietly eststo: areg `var' instrument $controls if birthyear_control >= 1970 & birthyear_control <= 1997, absorb(locale_gender) cluster(locale_3_control)
	
	noisily: lincom instrument 
	quietly: summ `var'
	estadd scalar vmean = r(mean)
	
}

foreach var of varlist `participation' {
	quietly eststo: reg `var' instrument c.instrument#c.W i.birthyear_control##c.W i.locale_gender##c.W c.post1##c.W c.treat2_10_inc##c.W $controls2 if birthyear_control >= 1970 & birthyear_control <= 1997, cluster(locale_3_control)
		
		display " "
		display " "
		display " "
		display "Table 2b: `var'"
		noisily: lincom instrument
		noisily: lincom c.instrument#c.W
		quietly: summ `var' if e(sample)
		estadd scalar vmean = r(mean)
}	

local numbers "& (1) & (2) & (3) \\"
local participation1 "\textbf{A: Main Effects} & \multicolumn{1}{c}{Participation index} &  \multicolumn{1}{c}{Participate index} &  \multicolumn{1}{c}{Contact index} \\  \midrule"
local participation2 "\midrule \\ \textbf{B: Democracy Threatened} & \multicolumn{1}{c}{Participation index} &  \multicolumn{1}{c}{Participate index}&  \multicolumn{1}{c}{Contact index} \\  \midrule"
local gap ""

esttab est1 est2 est3 using "tables/participation.tex", replace b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) nonumber posthead("`numbers'" "`participation1'") ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument)

esttab est4 est5 est6 using "tables/participation.tex", b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) ///
nonumber posthead("`gap'" "`participation2'") append ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument c.instrument#c.W)




************************************
***   Government and Democracy   ***
************************************


local democracy dem_gov dem_support dem_checks_on_pres dem_institutions
est clear


foreach var of varlist `democracy' {
	quietly eststo: areg `var' instrument $controls if birthyear_control >= 1970 & birthyear_control <= 1997, absorb(locale_gender) cluster(locale_3_control)
	
	display " "
	display " "
	display " "
	display "Table 2b: `var'"
	noisily: lincom instrument 
	quietly: summ `var'
	estadd scalar vmean = r(mean)
	
}

foreach var of varlist `democracy' {
	quietly eststo: reg `var' instrument c.instrument#c.W i.birthyear_control##c.W i.locale_gender##c.W c.post1##c.W c.treat2_10_inc##c.W $controls2 if birthyear_control >= 1970 & birthyear_control <= 1997, cluster(locale_3_control)
		
		display " "
		display " "
		display " "
		display "Table 3b: `var'"
		
		noisily: lincom instrument
		noisily: lincom c.instrument#c.W
		
		quietly: summ `var' if e(sample)
		estadd scalar vmean = r(mean)
}	

local numbers "& (1) & (2) & (3) & (4) \\"
local dem1 "\textbf{A: Support for Democracy} & \multicolumn{1}{c}{Democratic} &  \multicolumn{1}{c}{Dem support}&  \multicolumn{1}{c}{Checks on} &  \multicolumn{1}{c}{Dem institutions} \\ "
local dem2 "\midrule \\ \textbf{B: Democracy Threatened} & \multicolumn{1}{c}{Democratic} &  \multicolumn{1}{c}{Dem support}&  \multicolumn{1}{c}{Checks on} &  \multicolumn{1}{c}{Dem institutions} \\"
local line2 "& \multicolumn{1}{c}{quality index} &  \multicolumn{1}{c}{index}&  \multicolumn{1}{c}{president} &  \multicolumn{1}{c}{index} \\  \midrule"
local gap ""

esttab est1 est2 est3 est4 using "tables/democracy.tex", replace b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) nonumber posthead("`numbers'" "`dem1'"  "`line2'") ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument)

esttab est5 est6 est7 est8 using "tables/democracy.tex", b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) ///
nonumber posthead("`gap'" "`dem2'"  "`line2'") append ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument c.instrument#c.W)




*******************************
***   Governance measures   ***
*******************************


local governance corruption corruption_president performance_index
est clear


foreach var of varlist `governance' {
	display " "
	display " "
	display " "
	display "Table 4: `var'"
	
	quietly eststo: areg `var' instrument $controls if birthyear_control >= 1970 & birthyear_control <= 1997, absorb(locale_gender) cluster(locale_3_control)
	
	noisily: lincom instrument
	quietly: summ `var'
	estadd scalar vmean = r(mean)
}

foreach var of varlist `governance' {
	
	display " "
	display " "
	display " "
	display "Table 4: `var'"
	
	quietly eststo: reg `var' instrument c.instrument#c.W i.birthyear_control##c.W i.locale_gender##c.W c.post1##c.W c.treat2_10_inc##c.W $controls2 if birthyear_control >= 1970 & birthyear_control <= 1997, cluster(locale_3_control)
	
	noisily: lincom instrument 
	noisily: lincom c.instrument#c.W
	
	quietly: summ `var' if e(sample)
	estadd scalar vmean = r(mean)
		
}	

local numbers "& (1) & (2) & (3) & (4) & (5) & (6) \\"
local gov1 " & \multicolumn{1}{c}{Corruption} & \multicolumn{1}{c}{Pres. Corrupt} &  \multicolumn{1}{c}{Performance} & \multicolumn{1}{c}{Corruption} &  \multicolumn{1}{c}{Pres. Corrupt} &  \multicolumn{1}{c}{Performance} \\ \midrule"
local gap ""

esttab est1 est2 est3 est4 est5 est6 using "tables/governance.tex", replace b(3) se(3) ar(3) ///
stats(N vmean, fmt(0 3 3 "") labels(`"Observations"' `"DV Mean"')) nonumber posthead("`numbers'" "`gov1'") ///
f label nomtitles nogaps booktabs noobs compress star(* 0.10 ** 0.05 *** 0.01) keep(instrument c.instrument#c.W)


